import { Toast } from 'antd-mobile';
import { dreviewList } from '../../services/organization';

export default {
  namespace: 'dreviewLists',
  state: {
    data1:[],
  },
  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(({pathname, query}) => {
      })
    }
  },

  effects: {
    //获取民主评议列表
    *fetch({payload}, { call, put, select }) {
      const {data} = yield call(dreviewList, payload);
      console.log("data",data);
      if (data.code == 200) {
        yield put({
          type: 'success',
          payload: {
            data1: data.ret
          }
        })
        if (data.ret.data.length < 1) {
          Toast.fail("该组织下没有记录", 1);
        }

      }
      else {
        Toast.fail("查询出错", 1);
      }
    }

  },

  reducers: {
    success(state, action){
      return {...state, ...action.payload};
    }
  }
};
